package com.chinaums.sftp.internal.constants;

import org.apache.commons.lang3.StringUtils;

import java.io.IOException;
import java.util.Properties;

/**
 * constant value for file.
 */
public class ConstantValue {

    private static final Properties conf;

    static {
        conf = new Properties();
        try {
            conf.load(ConstantValue.class.getClassLoader().getResourceAsStream("conf.properties"));
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }


    public static final String SINGLE_SLASH_SYMBOL = "/";
    public static final String FILE_REGEX_SPLIT = "`";
    public static final String FILE_NEW_LINE = "\n";
    public static final String FILE_NEW_TAB = "\r";
    public static final String FILES_SPLIT = ",";
    public static final String EMPTY_REPLACE = "";

    public static final String SUFFIX_TAR_GZ = ".tar.gz";

    public static final String SUFFIX_ZIP = ".zip";
    public static final String SUFFIX_GZ = ".gz";

    public static final String SINGLE_STREAM = "SINGLE-STREAM";

    public static final String DRIVER = (String) conf.get("driver");
    public static final String URL = (String) conf.get("url");
    public static final String NAME = (String) conf.get("name");
    public static final String PASSWORD = (String) conf.get("password");

    public static final String TABLE = (String) conf.get("table");


    // 是否开启监控判断条件
    public static boolean isMetric() {

        return !StringUtils.isBlank(TABLE)
                && !StringUtils.isBlank(PASSWORD)
                && !StringUtils.isBlank(NAME)
                && !StringUtils.isBlank(URL)
                && !StringUtils.isBlank(DRIVER);
    }

}
